import { http } from "@/utils/http";
import { sysApi } from "@/config/env";

export type RefreshParamsResult = {
  success: boolean;
  data: {
    /** 验证码长度 */
    CAPTCHA_LENGTH: string;
    /** 是否先验证码图片 */
    LOGIN_CAPTCHA: boolean;
    /** websocket */
    WS_URL: string;
  };
};

// export const useParamsApi = (id: number) => {
// 	return service.get(`/${sysApi}/sys/params/` + id)
// }

/** 获取单个参数 */
export const paramsByKeyApi = (key: string) => {
  return http.request<RefreshParamsResult>(
    "get",
    sysApi + "/sys/params/getByKey/" + key
  );
};

/** 获取多个参数 */
export const paramsByKeysApi = (data?: object) => {
  return http.request<RefreshParamsResult>(
    "post",
    sysApi + "/sys/params/getByKeys",
    { data }
  );
};

// 获取多个参数
// export const useParamsByKeysApi = (keys: string[]) => {
// 	return service.post(`/${sysApi}/sys/params/getByKeys`, keys)
// }

// export const useParamsSubmitApi = (dataForm: any) => {
// 	if (dataForm.id) {
// 		return service.put(`/${sysApi}/sys/params`, dataForm)
// 	} else {
// 		return service.post(`/${sysApi}/sys/params`, dataForm)
// 	}
// }
